<?php
session_start();
if (isset($_SESSION["username"])) {
?>
  <?php require_once('common/header.php'); ?>
  <!--页面主要内容-->
 <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <ul class="nav nav-tabs page-tabs">
                <li class="active"> <a href="ltapi.php">联通配置</a> </li>
                <li> <a href="dxapi.php">电信配置</a> </li>
                <li> <a href="ydapi.php">移动配置</a> </li>
              </ul>
              <?php
              include_once("../untils/conn.php");
                $groups = 'Unicom';
                $sql = "SELECT * FROM config_api WHERE groups = '$groups'";
                $result = mysqli_query($con, $sql);
                
                // 检查查询结果是否为空
                if (mysqli_num_rows($result) > 0) {
                    // 获取第一行数据
                    $row = mysqli_fetch_assoc($result);
                
                    // 提取需要的字段值
                    $channel = $row['channel'];
                    $uid = $row['uid'];
                    $historyId = $row['historyId'];
                    $unicomMallUid = $row['unicomMallUid'];
                    $referer = $row ['referer'];
                    $pageKey = $row ['pageKey'];
            
                } else {
                    // 没有找到匹配的数据
                    // 可以在此处设置默认值或其他处理方式
                    // $channel = '';
                    // $uid = '';
                    // $historyId = '';
                }
                
              ?>
               <div class="">
                <div class="card-body">
                 <form class="form-horizontal" action="controller/doLtConfig.php" method="POST">
                    <div class="form-group">
                        <label for="title" class="col-xs-12">联通渠道码：</label>
                        <div class="col-xs-12">
                            <input type="text" class="form-control" name="channel" placeholder="联通渠道码" value="<?php echo $channel; ?>" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="title" class="col-xs-12">联通UID：</label>
                        <div class="col-xs-12">
                            <input type="text" class="form-control" name="uid" placeholder="联通UID" value="<?php echo $uid; ?>" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="title" class="col-xs-12">联通历史id：</label>
                        <div class="col-xs-12">
                            <input type="text" class="form-control" name="historyId" placeholder="未知参数但是必填" value="<?php echo $historyId; ?>" required>
                        </div>
                    </div>
                     <div class="form-group">
                        <label for="title" class="col-xs-12">未知参数（unicomMallUid）：</label>
                        <div class="col-xs-12">
                            <input type="text" class="form-control" name="unicomMallUid" placeholder="未知参数但是必填" value="<?php echo $unicomMallUid; ?>" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="title" class="col-xs-12">下单链接（接口需要校验）：</label>
                        <div class="col-xs-12">
                            <input type="text" class="form-control" name="referer" placeholder="下单链接必填" value="<?php echo $referer; ?>" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="title" class="col-xs-12">页码key（接口需要校验）：</label>
                        <div class="col-xs-12">
                            <input type="text" class="form-control" name="pageKey" placeholder="下单页pageKey需校验" value="<?php echo $pageKey ;?>" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <input type="hidden" name="groups" value="<?php echo $groups ?>">
                        <div class="offset-2 col-xs-12">
                            <button class="btn btn-success" type="submit" value="添加">确认修改</button>
                        </div>
                    </div>
                </form>

                </div>
              </div>

            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
  <!--End 页面主要内容-->
  <?php require_once('common/footer.php'); ?>
<?php
} else {
  echo "<script>alert('您尚未登录，没有权限访问该页面');location.href='login.php';</script>";
}
